package com.ktgj.other.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.other.domain.RcOrderInvoiceOptlog;
import com.ktgj.other.service.IRcOrderInvoiceOptlogService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 专车订单发票日志Controller
 * 
 * @author ruoyi
 * @date 2022-07-27
 */
@RestController
@RequestMapping("/optlog")
public class RcOrderInvoiceOptlogController extends BaseController
{
    @Autowired
    private IRcOrderInvoiceOptlogService rcOrderInvoiceOptlogService;

    /**
     * 查询专车订单发票日志列表
     */
    @PreAuthorize(hasPermi = "other:optlog:list")
    @GetMapping("/list")
    public TableDataInfo list(RcOrderInvoiceOptlog rcOrderInvoiceOptlog)
    {
        startPage();
        List<RcOrderInvoiceOptlog> list = rcOrderInvoiceOptlogService.selectRcOrderInvoiceOptlogList(rcOrderInvoiceOptlog);
        return getDataTable(list);
    }

    /**
     * 导出专车订单发票日志列表
     */
    @PreAuthorize(hasPermi = "other:optlog:export")
    @Log(title = "专车订单发票日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RcOrderInvoiceOptlog rcOrderInvoiceOptlog) throws IOException
    {
        List<RcOrderInvoiceOptlog> list = rcOrderInvoiceOptlogService.selectRcOrderInvoiceOptlogList(rcOrderInvoiceOptlog);
        ExcelUtil<RcOrderInvoiceOptlog> util = new ExcelUtil<RcOrderInvoiceOptlog>(RcOrderInvoiceOptlog.class);
        util.exportExcel(response, list, "专车订单发票日志数据");
    }

    /**
     * 获取专车订单发票日志详细信息
     */
    @PreAuthorize(hasPermi = "other:optlog:query")
    @GetMapping(value = "/{rcorderinvoiceoptlogid}")
    public AjaxResult getInfo(@PathVariable("rcorderinvoiceoptlogid") Long rcorderinvoiceoptlogid)
    {
        return AjaxResult.success(rcOrderInvoiceOptlogService.selectRcOrderInvoiceOptlogById(rcorderinvoiceoptlogid));
    }

    /**
     * 新增专车订单发票日志
     */
    @PreAuthorize(hasPermi = "other:optlog:add")
    @Log(title = "专车订单发票日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RcOrderInvoiceOptlog rcOrderInvoiceOptlog)
    {
        return toAjax(rcOrderInvoiceOptlogService.insertRcOrderInvoiceOptlog(rcOrderInvoiceOptlog));
    }

    /**
     * 修改专车订单发票日志
     */
    @PreAuthorize(hasPermi = "other:optlog:edit")
    @Log(title = "专车订单发票日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RcOrderInvoiceOptlog rcOrderInvoiceOptlog)
    {
        return toAjax(rcOrderInvoiceOptlogService.updateRcOrderInvoiceOptlog(rcOrderInvoiceOptlog));
    }

    /**
     * 删除专车订单发票日志
     */
    @PreAuthorize(hasPermi = "other:optlog:remove")
    @Log(title = "专车订单发票日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rcorderinvoiceoptlogids}")
    public AjaxResult remove(@PathVariable Long[] rcorderinvoiceoptlogids)
    {
        return toAjax(rcOrderInvoiceOptlogService.deleteRcOrderInvoiceOptlogByIds(rcorderinvoiceoptlogids));
    }
}
